#!/bin/bash
#describe:备份gitlab中postgresql数据库中gitlabhq_production库中的数据
#以便在备机postgresql中恢复
#gitlab-psql默认用户
su - gitlab-psql <<EOF 
pg_dump -h 192.168.1.248 -d gitlabhq_production -f gitlab`date +%Y%m%d`.sql
EOF
scp /var/opt/gitlab/postgresql/gitlab`date +%Y%m%d`.sql root@k8s2-master2:/var/opt/gitlab/postgresql
find /var/opt/gitlab/postgresql/ -mtime +10 -name '*.sql' -exec rm -rf {} \;